package com.kun.gulimall.guliproduct.controller;

import com.kun.gulimall.guliproduct.query.BrandQuery;
import com.kun.gulimall.guliproduct.service.PmsBrandService;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/brand")
@AllArgsConstructor
public class BrandController {

    private PmsBrandService brandService;

    @GetMapping("/page")
    public ResponseEntity<Object> list(BrandQuery brandQuery) {
        return ResponseEntity.ok(brandService.getBrandPage(brandQuery));
    }

    /**
     * 新增
     */
    @PostMapping
    public ResponseEntity<Object> save(@Validated @RequestBody BrandQuery brandQuery) {
        return ResponseEntity.ok(brandService.saveBrand(brandQuery));
    }

    /**
     * 修改
     */
    @PutMapping
    public ResponseEntity<Object> update(@RequestBody BrandQuery brandQuery) {
        return ResponseEntity.ok(brandService.updateByBrandId(brandQuery));
    }

}
